import sys
from antGP import *
import antPickel
import game

def update_board(current_board):
    ''' Prints the board to the command line.
    
        This functions can be replaced with one that updates the board in
        the graphics.
    '''
    print current_board

def main_run():
    # Check if opening chromosome or creating new one
    bestChrom = None
    if len(sys.argv) == 2:
        (chrom, seed) = antPickel.unpickle_chromosome(sys.argv[1])
        game.get_board(seed)    # Set seed for all future boards
        bestChrom = chrom
    else:
        antProblem = AntGP()
        antProblem.run_ga(5)
        bestChrom = antProblem.best_individual()
    
    # Display the path of the ant
    print "Path:"
    path = get_boards_for_chromosome(bestChrom)
    for b in path:
        print b
        print

    # Display Statistics on the ant
    print bestChrom
    print "Missed:", evalfun_morsels_left(bestChrom), "out of", game.MORSEL_CNT

if __name__ == "__main__":
    main_run()
